package com.subang.function.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.subang.common.annotation.Log;
import com.subang.common.core.controller.BaseController;
import com.subang.common.core.domain.AjaxResult;
import com.subang.common.enums.BusinessType;
import com.subang.function.domain.SbCurrentPoliticsQuestion;
import com.subang.function.service.ISbCurrentPoliticsQuestionService;
import com.subang.common.utils.poi.ExcelUtil;
import com.subang.common.core.page.TableDataInfo;

/**
 * 时政热点题Controller
 * 
 * @author subei
 * @date 2025-03-25
 */
@RestController
@RequestMapping("/function/question")
public class SbCurrentPoliticsQuestionController extends BaseController
{
    @Autowired
    private ISbCurrentPoliticsQuestionService sbCurrentPoliticsQuestionService;

    /**
     * 查询时政热点题列表
     */
    @GetMapping("/list")
    public AjaxResult list(SbCurrentPoliticsQuestion sbCurrentPoliticsQuestion)
    {
        List<SbCurrentPoliticsQuestion> list = sbCurrentPoliticsQuestionService.selectSbCurrentPoliticsQuestionList(sbCurrentPoliticsQuestion);
        return AjaxResult.success(list);
    }

    /**
     * 导出时政热点题列表
     */
    @PreAuthorize("@ss.hasPermi('function:question:export')")
    @Log(title = "时政热点题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SbCurrentPoliticsQuestion sbCurrentPoliticsQuestion)
    {
        List<SbCurrentPoliticsQuestion> list = sbCurrentPoliticsQuestionService.selectSbCurrentPoliticsQuestionList(sbCurrentPoliticsQuestion);
        ExcelUtil<SbCurrentPoliticsQuestion> util = new ExcelUtil<SbCurrentPoliticsQuestion>(SbCurrentPoliticsQuestion.class);
        util.exportExcel(response, list, "时政热点题数据");
    }

    /**
     * 获取时政热点题详细信息
     */
    @PreAuthorize("@ss.hasPermi('function:question:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sbCurrentPoliticsQuestionService.selectSbCurrentPoliticsQuestionById(id));
    }

    /**
     * 新增时政热点题
     */
    @PreAuthorize("@ss.hasPermi('function:question:add')")
    @Log(title = "时政热点题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SbCurrentPoliticsQuestion sbCurrentPoliticsQuestion)
    {
        return toAjax(sbCurrentPoliticsQuestionService.insertSbCurrentPoliticsQuestion(sbCurrentPoliticsQuestion));
    }

    /**
     * 修改时政热点题
     */
    @PreAuthorize("@ss.hasPermi('function:question:edit')")
    @Log(title = "时政热点题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SbCurrentPoliticsQuestion sbCurrentPoliticsQuestion)
    {
        return toAjax(sbCurrentPoliticsQuestionService.updateSbCurrentPoliticsQuestion(sbCurrentPoliticsQuestion));
    }

    /**
     * 删除时政热点题
     */
    @PreAuthorize("@ss.hasPermi('function:question:remove')")
    @Log(title = "时政热点题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sbCurrentPoliticsQuestionService.deleteSbCurrentPoliticsQuestionByIds(ids));
    }
}
